import java.util.Scanner;

public class P1047 {
    public static void main(String args[]){
        int length,region_count;
        Scanner sc = new Scanner(System.in);
        length = sc.nextInt()+1;
        region_count = sc.nextInt();
        int arr[] = new int[length];
        int start_index,end_index;
        for (int i = 0; i < region_count; i++){
            start_index = sc.nextInt();
            end_index = sc.nextInt();
            for (int j = start_index; j <= end_index; j++){
                arr[j] = 1;
            }
        }

        int count  = 0;
        for (int i = 0; i < length; i++){
            if (arr[i] == 0){
                count++;
            }
        }

        System.out.println(count);
    }
}
